/**
 * @Method buttonGroup
 * @Description TODO
 * @Date 2021/1/20 15:08
 * @Created by HePing
 */
export default {
  model: {
    prop: 'model'
  },
  props: {
    model: {},
    config: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  render(h) {
    const vm = this
    const { widget: { style, props, className }, buttonGroup } = vm.config
    const children = buttonGroup.map(({ label, attrs, style, props, uid }, i) => {
      return h(
        'el-button',
        {
          attrs,
          style,
          props,
          on: {
            click(event) {
              const fn = vm.$listeners.click
              if (fn) {
                fn.call(event, { event, uid: uid || label })
              }
            }
          }
        },
        label
      )
    })
    return (
      <div class={['ve-button-group', className]} style={{
        ...style,
        'text-align': props && props.position || 'left'
      }}>
        {children}
      </div>
    )
  }
}
